Skip to content

Conversation

@Kota-Jagadeesh
Copy link
Collaborator

@Kota-Jagadeesh Kota-Jagadeesh commented Oct 13, 2025

Description (required)

Fixes #3101

Implemented a strict 20-image selection and upload limit in the Wikimedia Commons app to prevent server overload and align with user feedback. Modified CustomSelectorActivity.kt and ImageAdapter.kt to restrict selection to 5 images, updated UploadActivity.kt to process only 5 images, added a close button in item_custom_selector_image.xml for deselection, updated custom_selector_limit_dialog.xml and strings.xml for a clear 5-image limit message, and ensured ThumbnailsAdapter.kt displays only 5 images in the upload UI thumbnail bar.

@Kota-Jagadeesh
Copy link
Collaborator Author

Kota-Jagadeesh commented Oct 14, 2025

@nicolas-raoul Changed from 5 image limit to 20 image limit as per #3101 (comment)

@Kota-Jagadeesh
Copy link
Collaborator Author

@nicolas-raoul - Made the required changes.
If you have time can you please look into the PR : )

@nicolas-raoul
Copy link
Member

I am travelling (now Hyderabad) so I can't test, but I hope I will be able to do it on Wednesday. Or someone might do it before me. Thank you for your understanding! 🙂

@Kota-Jagadeesh
Copy link
Collaborator Author

I am travelling (now Hyderabad) so I can't test, but I hope I will be able to do it on Wednesday. Or someone might do it before me. Thank you for your understanding! 🙂

Oh, Hyderabad! Wishing you a pleasant journey. I hope you get the chance to explore and enjoy the beauty of the city.

@Kota-Jagadeesh Kota-Jagadeesh self-assigned this Nov 13, 2025
@nicolas-raoul
Copy link
Member

With this branch, I shared 63 pictures to the app, and saw nothing special:

Screenshot_20251115-220050.png

Is it intended?

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, is this branch only about the system picker inside the app? And #6556 is about sharing to the Commons app from another app?

With this branch, when system picker is used, truncation indeed happens correctly. I did not see a toast, though.

By the way, with this branch I do not see thumbnails anymore in the custom picker.

numberOfSelectedImagesMarkedAsNotForUpload = 0
images.clear()
selectedImages = arrayListOf()
selectedImages = ArrayList(selectedImages.take(5)) // enforce the 5-image limit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using MAX_IMAGE_COUNT here?

holder.itemView.setOnClickListener {
if (!holder.isItemUploaded() && !holder.isItemNotForUpload()) {
if (selectedImages.size >= MAX_IMAGE_COUNT && !isSelected) { //enforce the 20-image limit
Toast.makeText(context, "Cannot select more than 20 images", Toast.LENGTH_SHORT).show()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using MAX_IMAGE_COUNT in the toast?

uploadingContributionList,
)
scope.launch {
val sharedPreferences: SharedPreferences =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this part not useful? Does the Show already handled pictures still work as intended?

@Kota-Jagadeesh
Copy link
Collaborator Author

Okay, this one was a bit of a mess and I fully own that.

Originally I tried to slap the 20-image limit in a bunch of places half-heartedly, which led to inconsistent behavior (some paths respected the limit, some didn’t, toast missing, thumbnails sometimes broken, etc.).

After properly fixing the external share -> Commons flow in #6556, I finally understood the cleanest way to do it, so I came back and cleaned up this branch completely.

What this PR now does correctly and consistently:

  • Enforces exactly 20 images max
  • Shows a clear toast when user picks >20: "You've selected more than X images. Only the first 20 will be uploaded."
  • Thumbnails in custom selector are working again (regression fixed)
  • Uses MAX_IMAGE_COUNT constant everywhere (no magic numbers)
  • Close button (X) properly appears/disappears on selection
  • All the weird take(5) hacks are gone

I’ll open the follow-up PR tomorrow that unifies both flows and removes duplicated code : )

@Kota-Jagadeesh
Copy link
Collaborator Author

@nicolas-raoul Updated th PR with all the required changes, Please review it : )

@Kota-Jagadeesh
Copy link
Collaborator Author

Ah, is this branch only about the system picker inside the app? And #6556 is about sharing to the Commons app from another app?

Yeah, exactly.

@github-actions
Copy link

✅ Generated APK variants!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit on number of images uploaded at once

2 participants